import request from '@/utils/request'
import {getToken} from "@/utils/auth";

export function login(obj) {
  let data=JSON.parse(obj)
  const params = {
    username: data.username,
    password: data.password,
    grant_type: 'password',
    code: data.code,
    scope: 'server'
  }
  return request({
    url: '/auth/oauth/token',
    method: 'post',
    headers: {
      'Authorization': 'Basic cGlnOnBpZw=='
    },
    params
  })
}

export function getInfo() {
  return request({
    url: 'admin/sysUser/user-info',
    method: 'get'
  })
}

export function getCodeImg() {
  return request({
    url: '/auth/token/code',
    method: 'get'
  })
}

export function logout() {
  return request({
    url: '/auth/token/logout',
    method: 'delete',
    headers: {
      'Authorization': getToken()
    },
  })
}
